package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.pojo.TCheckitem;
import com.qf.service.TCheckitemService;
import com.qf.mapper.TCheckitemMapper;
import com.qf.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【t_checkitem】的数据库操作Service实现
* @createDate 2024-07-17 22:32:22
*/
@Service
@RequiredArgsConstructor
public class TCheckitemServiceImpl extends ServiceImpl<TCheckitemMapper, TCheckitem>
    implements TCheckitemService{
    private final TCheckitemMapper checkitemMapper;
    @Override
    public Result listCheckitemPage(int page, int pageSize, String queryString) {
        LambdaQueryWrapper<TCheckitem> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.hasText(queryString),TCheckitem::getName,queryString)
                .or().like(StringUtils.hasText(queryString),TCheckitem::getCode,queryString);

        Page<TCheckitem> p = new Page<>(page, pageSize);
        Page<TCheckitem> TCheckitemPage =checkitemMapper.selectPage(p, wrapper);
        return new Result(true,"查询成功",TCheckitemPage);
    }

    @Override
    public void add(TCheckitem checkitem) {
        checkitemMapper.insert(checkitem);

    }

    @Override
    public Result findById(int id) {
        TCheckitem checkitem = checkitemMapper.selectById(id);
        return new Result(true,"查询成功",checkitem);
    }

    @Override
    public Result findAll() {
        return new Result(true,"查询成功",checkitemMapper.selectList(null));
    }
}




